package com.git.hui.yinshua.common.id;

/**
 * @author YiHui
 * @date 2024/6/20
 */
public class OrderIdGen {
    private static SnowflakeIdGenerator generator = new SnowflakeIdGenerator();

    public static Long genOrderId() {
        return generator.nextId();
    }

    /**
     * 支付单生成器
     *
     * @return
     */
    public static Long genPayId() {
        return Long.parseLong("1" + genOrderId());
    }

    public static Long genRefundId() {
        return Long.parseLong("3" + genOrderId());
    }

    public static void main(String[] args) throws InterruptedException {
        Long orderId = genOrderId();
        Long orderId2 = genOrderId();
        Long orderId3 = genOrderId();
        System.out.println(orderId + "\n" + orderId2 + "\n" + orderId3);
        Thread.sleep(1100);

        for (int i = 0; i < 100; i++) {
            orderId = genOrderId();
            orderId2 = genOrderId();
            orderId3 = genOrderId();
            System.out.println(orderId + "\n" + orderId2 + "\n" + orderId3);
        }

        Thread.sleep(2001);
        orderId = genOrderId();
        orderId2 = genOrderId();
        orderId3 = genOrderId();
        System.out.println(orderId + "\n" + orderId2 + "\n" + orderId3);
    }
}
